import 'package:flutter/material.dart';

class CustomRouter extends PageRouteBuilder {
  final Widget widget;
  CustomRouter(this.widget) : super(
    transitionDuration: Duration(seconds: 1), // 动画时间
    pageBuilder: (BuildContext context, Animation<double> animation1,
        Animation<double> animation2) {
      return widget;
    },
    transitionsBuilder: (BuildContext context,
        Animation<double> animation1,
        Animation<double> animation2,
        Widget child) {

      // return FadeTransition( // 渐隐渐现过渡效果
      //   opacity: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
      //     parent: animation1,
      //     curve: Curves.fastOutSlowIn, // 动画曲线
      //   )),
      //   child: child,
      // );

      // return ScaleTransition( // 缩放的效果
      //   scale: Tween(begin:0.0,end:1.0).animate(CurvedAnimation(
      //     parent: animation1,
      //     curve: Curves.fastOutSlowIn
      //   )),
      //   child: child,
      // );

      // return RotationTransition( // 旋转的效果
      //   turns: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
      //     parent: animation1,
      //     curve: Curves.fastOutSlowIn,
      //   )),
      //   child: child,
      // );

      // return SlideTransition( // 左右滑动的效果
      //   position: Tween(begin: Offset(1.0,0.0), end:Offset(0.0,0.0)).animate(CurvedAnimation(
      //     parent: animation1,
      //     curve: Curves.fastOutSlowIn
      //   )),
      //   child: child,
      // );

      // return RotationTransition( // 旋转的效果
      //   turns: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
      //     parent: animation1,
      //     curve: Curves.fastOutSlowIn,
      //   )),
      //   child: ScaleTransition( // 缩放效果
      //     scale: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
      //       parent: animation1,
      //       curve: Curves.fastOutSlowIn
      //     )),
      //     child: child,
      //   ),
      // );

      return SlideTransition( // 左右滑动的效果
        position: Tween(begin: Offset(-1.0,0.0), end:Offset(0.0,0.0)).animate(CurvedAnimation(
            parent: animation1,
            curve: Curves.fastOutSlowIn
        )),
        child: ScaleTransition( // 缩放效果
          scale: Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
            parent: animation1,
            curve: Curves.fastOutSlowIn
          )),
          child: child,
        ),
      );

    }
  );
}
